package com.cn.yang.servlet.message;

import com.alibaba.fastjson.JSONObject;
import com.cn.yang.service.MessageService;
import com.cn.yang.service.NewsService;
import com.cn.yang.service.impl.MessageServiceImpl;
import com.cn.yang.service.impl.NewsServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/back/message/deleteMessageById")
public class DeleteMessageByIdServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("UTF-8");
        resp.setCharacterEncoding("UTF-8");

        Integer id = Integer.valueOf(req.getParameter("id"));
        MessageService service = new MessageServiceImpl();
        int result = service.deleteById(id);
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("result",result);
        resp.getWriter().println(jsonObject);
    }
}
